home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / standard / sigfpe.z / sigfpe
Encoding:
Text File  |  2002-10-03  |  31.7 KB  |  678 lines

  1. SIGFPE(3C)                                            Last changed: 9-22-98
  2.  
  3.  
  4. NNAAMMEE
  5.      hhaannddllee__ssiiggffppeess - Floating-point exception handler package
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssiiggffppee..hh>>
  9.  
  10.      vvooiidd hhaannddllee__ssiiggffppeess ((iinntt oonnooffff,, iinntt eenn__mmaasskk,,
  11.                           vvooiidd ((**uusseerr__rroouuttiinnee))((uunnssiiggnneedd[[55]],, iinntt[[22]])),,
  12.                           iinntt aabboorrtt__aaccttiioonn,,
  13.                           vvooiidd ((**aabboorrtt__rroouuttiinnee))((uunnssiiggnneedd iinntt ****))));;
  14.                              vvooiidd ((**uusseerr__rroouuttiinnee))((uunnssiiggnneedd[[55]],, iinntt[[22]])),,
  15.                              iinntt aabboorrtt__aaccttiioonn,,
  16.                              vvooiidd ((**aabboorrtt__rroouuttiinnee))((uunnssiiggnneedd iinntt ****))));;
  17.  
  18.      ttyyppeeddeeff vvooiidd ((**uusseerr__tt))((uunnssiiggnneedd[[55]],, iinntt[[22]]));;
  19.  
  20.      ttyyppeeddeeff vvooiidd ((**aabboorrtt__tt))((uunnssiiggnneedd iinntt ****));;
  21.  
  22.      ssttrruucctt ssiiggffppee__tteemmppllaattee
  23.           {{
  24.           iinntt rreeppllss;;
  25.           iinntt ccoouunntt;;
  26.           iinntt ttrraaccee;;
  27.           iinntt aabboorrtt;;
  28.           iinntt eexxiitt;;
  29.           }};;
  30.  
  31.      eexxtteerrnn ssttrruucctt ssiiggffppee__tteemmppllaattee ssiiggffppee__[[__NN__EEXXCCEEPPTTIIOONN__TTYYPPEESS++11]];;
  32.  
  33.      eexxtteerrnn iinntt iinnvvaalliiddoopp__rreessuullttss__[[__NN__IINNVVAALLIIDDOOPP__RREESSUULLTTSS++11]];;
  34.  
  35.      eexxtteerrnn iinntt iinnvvaalliiddoopp__ooppeerraannddss__[[__NN__IINNVVAALLIIDDOOPP__OOPPEERRAANNDDSS++11]];;
  36.  
  37. IIMMPPLLEEMMEENNTTAATTIIOONN
  38.      IRIX systems
  39.  
  40. DDEESSCCRRIIPPTTIIOONN
  41.      The floating-point accelerator may raise floating-point exceptions,
  42.      signal SSIIGGFFPPEE, due to five conditions:  __OOVVEERRFFLL(_o_v_e_r_f_l_o_w),
  43.      __UUNNDDEERRFFLL(_u_n_d_e_r_f_l_o_w), __DDIIVVZZEERROO(_d_i_v_i_d_e-_b_y-_z_e_r_o), __IINNEEXXAACCTT(_i_n_e_x_a_c_t
  44.      _r_e_s_u_l_t), or __IINNVVAALLIIDD(_i_n_v_a_l_i_d _o_p_e_r_a_n_d, e.g., infinity).  Usually these
  45.      conditions are masked, and do not cause a floating-point exception.
  46.      Instead, a default value is substituted for the result of the
  47.      operation, and the program continues silently.  This event may be
  48.      intercepted by causing an exception to be raised.  When this occurs,
  49.      the operating system generates a SIGFPE signal.
  50.  
  51.      The integer arithmetic instructions aadddd, aaddddii, ddaadddd, ddaaddddii, ssuubb, and
  52.      ddssuubb also generate a SIGFPE signal when the result of the operation
  53.      overflows (condition __IINNTT__OOVVEERRFFLL).  (Currently, SGI compilers generate
  54.      only uunnssiiggnneedd versions of these instructions, which do not generate a
  55.      signal on overflow.  However, it is still possible to generate these
  56.      instructions via assembly language).
  57.  
  58.      For --oo3322 programs, the compiler generates additional instructions to
  59.      detect and trap on integer-divide-by-zero.  No similar detection code
  60.      sequences are generated in --nn3322 or --6644 programs.
  61.  
  62.      Once an exception is raised, the specific conditions which caused the
  63.      exception may be determined, and more appropriate action taken.
  64.  
  65.      The lliibbffppee..ssoo library provides two methods to unmask and handle these
  66.      conditions: the subroutine hhaannddllee__ssiiggffppeess, and the environment
  67.      variable TTRRAAPP__FFPPEE.  Both methods provide a mechanism for unmasking
  68.      each of these conditions except __IINNEEXXAACCTT, for handling and classifying
  69.      exceptions arising from them, and for substituting either a default
  70.      value or a chosen one.  They also provide mechanisms to count, trace,
  71.      exit or abort on enabled exceptions.  If you supply your own call to
  72.      hhaannddllee__ssiiggffppeess, you should leave environment variable TTRRAAPP__FFPPEE
  73.      undefined or set to OFF.  TTRRAAPP__FFPPEE is supported for Fortran, C, C++
  74.      and Pascal.  hhaannddllee__ssiiggffppeess is supported for C, C++ and Fortran.
  75.  
  76.      Calling the subroutine is the preferred method when preparing software
  77.      for others to use, since it relieves the user of any need to know
  78.      about the TTRRAAPP__FFPPEE environment variable.
  79.  
  80.      The environment variable is preferable if you want to experiment or
  81.      allow any user to experiment with different trap behaviors with
  82.      minimum effort.
  83.  
  84.      lliibbffppee uses System V signal handling and will not work with programs
  85.      that use Berkeley signal handling.
  86.  
  87.      Note that the preferred method for flushing denormals to zero is to
  88.      set the FS bit to 1 in the floating point control status register.  If
  89.      the FS bit is set to 1, the user should not handle underflows through
  90.      the floating point trap handler, because a denormal result flushed to
  91.      zero will cause an underflow.  Note that calls to the floating point
  92.      trap handler consume many thousands of cpu cycles.  The following
  93.      routine (written in C) can be used to set/clear the FS bit.
  94.  
  95.           #include <sys/fpu.h>
  96.  
  97.           void
  98.           flush_to_zero(int on_off)
  99.           {
  100.           union fpc_csr  n;
  101.  
  102.                n.fc_word = get_fpc_csr();
  103.                if ( on_off == 0 ) {
  104.                     n.fc_struct.flush = 0;
  105.                } else {
  106.                     n.fc_struct.flush = 1;
  107.                }
  108.                set_fpc_csr(n.fc_word);
  109.           }
  110.  
  111.      Note that if the FS bit in the floating point control status register
  112.      is set, it remains set after calling hhaannddllee__ssiiggffppeess((__OOFFFF,, ......
  113.  
  114.      Be sure to read the NOTES FOR R8000 section on this man page, which
  115.      describes the behavior of lliibbffppee..ssoo on the R8000 processor.
  116.  
  117. HHAANNDDLLEE__SSIIGGFFPPEESS SSUUBBRROOUUTTIINNEE
  118.      The values in the global arrays are described in the ""WWHHEENN AANN
  119.      EEXXCCEEPPTTIIOONN IISS EENNCCOOUUNNTTEERREEDD"" section on this man page.
  120.  
  121.      The arguments to hhaannddllee__ssiiggffppeess are as follows:
  122.  
  123.      oonnooffff
  124.           Indicates whether handling is turned on ((oonnooffff ==== __OONN)) or off
  125.           ((oonnooffff ==== __OOFFFF)).  Specifying ((oonnooffff ==== __DDEEBBUUGG)) is another way to
  126.           turn on handling.  Information from the ssiiggffppee structure will be
  127.           printed if ((oonnooffff ==== __DDEEBBUUGG)).  (The names used in this document
  128.           are defined in ssiiggffppee..hh.)
  129.  
  130.      eenn__mmaasskk
  131.           Indicates which of the five conditions should be unmasked,
  132.           enabling them to raise floating-point exceptions/or an integer
  133.           overflow exception.  eenn__mmaasskk is valid only if oonnooffff ==== __OONN  or
  134.           oonnooffff ==== __DDEEBBUUGG, and is the bitwise or of one or more of the
  135.           constants _EN_UNDERFL, _EN_OVERFL, _EN_DIVZERO, _EN_INVALID, and
  136.           _EN_INT_OVERFL (defined in ssiiggffppee..hh).
  137.  
  138.      uusseerr__rroouuttiinnee::
  139.           hhaannddllee__ssiiggffppeess provides a mechanism for setting the result of the
  140.           operation to any one of a set of well-known values.  If full
  141.           control over the value of selected operations is desired for one
  142.           or more exception conditions, a function uusseerr__rroouuttiinnee must be
  143.           provided.  For these selected exception conditions, uusseerr__rroouuttiinnee
  144.           will be called to set the value resulting from the operation.
  145.           Pass a 0 (plain 0 is adequate) if you do not want to provide a
  146.           uusseerr__rroouuttiinnee.  Typedef uusseerr__tt is defined in ssiiggffppee..hh for
  147.           convenience in programming.
  148.  
  149.      aabboorrtt__aaccttiioonn::
  150.           If the handler encounters an unexpected condition or an
  151.           inconsistency, the flag aabboorrtt__aaccttiioonn indicates what action should
  152.           be taken.  Another option is for you to specify that you are
  153.           supplying your own floating point exception handler as the
  154.           default handler.  The following legal values can be specified:
  155.  
  156.           _TURN_OFF_HANDLER_ON_ERROR
  157.                Instruct the floating-point-accelerator to cease causing
  158.                exceptions and continue (i.e., disable handling).
  159.  
  160.           _ABORT_ON_ERROR
  161.                Kill the process after giving an error message and calling a
  162.                user-supplied cleanup routine if one is provided via the
  163.                aabboorrtt__rroouuttiinnee parameter.
  164.  
  165.           _REPLACE_HANDLER_ON_ERROR
  166.                Install the indicated user routine as the handler when such
  167.                an error is encountered.  Future floating-point exceptions
  168.                will branch to the user-routine (see ssiiggnnaall(2)).
  169.  
  170.           _USER_HANDLER
  171.                Install the indicated user routine as the handler
  172.                immediately.  Future floating-point exceptions will branch
  173.                to the user-routine (see ssiiggnnaall(2)).
  174.  
  175.      aabboorrtt__rroouuttiinnee::
  176.           When a fatal error (i.e., one described under aabboorrtt__aaccttiioonn) is
  177.           encountered, aabboorrtt__rroouuttiinnee is used as the address of a user
  178.           routine.
  179.  
  180.           If abort_action is _ABORT_ON_ERROR, and aabboorrtt__rroouuttiinnee is valid,
  181.           it is called before aborting, and passed a pointer to the address
  182.           of the instruction causing the exception as its single argument.
  183.           In this case, the user's abort_routine should be defined as
  184.           follows:
  185.  
  186.           void abort_routine( ptr_to_pc )
  187.           unsigned int **ptr_to_pc;
  188.  
  189.      If aabboorrtt__aaccttiioonn is _REPLACE_HANDLER_ON_ERROR, and aabboorrtt__rroouuttiinnee is
  190.      valid, it will be installed as the new handler.  In this case,
  191.      aabboorrtt__rroouuttiinnee will be called immediately to handle the current
  192.      exception.  (see ssiiggnnaall(2)) Pass a 0 (plain 0 is adequate) if you do
  193.      not want to provide an aabboorrtt__aaccttiioonn routine.
  194.  
  195.      If aabboorrtt__aaccttiioonn is _USER_HANDLER, and aabboorrtt__rroouuttiinnee is valid, it will
  196.      be installed immediately as the default floating point exception
  197.      handler.
  198.  
  199.      If aabboorrtt__rroouuttiinnee is to be invoked as a floating point exception
  200.      handler, the following prototype should be used (see <<ssiiggffppee..hh>>,
  201.      <<ssyyss//ssiiggnnaall..hh>>, and ssiiggnnaall(2)):
  202.  
  203.           int user_handler( sig, code, sc )
  204.           int sig, code;
  205.           struct sigcontext *sc;
  206.  
  207.      Typedef aabboorrtt__tt is defined in ssiiggffppee..hh for convenience in programming.
  208.  
  209.      Routine user_handler should return 0 to continue processing of the
  210.      user's code and a non-zero value to disconnect user_handler as the
  211.      floating point exception handler.  User_handler should not issue a
  212.      call to ssiiggnnaall(), nor should it update the program counter in the
  213.      sigcontext area, because these actions are done in the routine which
  214.      calls it.  A user handler can determine which type of exception has
  215.      occurred by calling routine ____ffppee__ttrraapp__ttyyppee().  This routine returns
  216.      one of _UNDERFL, _OVERFL, etc. as appropriate.
  217.  
  218.      Users can supply separate handlers for each exception type by making
  219.      multiple calls to handle_sigfpes.  See example 3 that follows.
  220.      Similarly, trap handling for one or more exception types can be turned
  221.      off by or-ing the appropriate combination of masks in the second
  222.      parameter to handle_sigfpes.
  223.  
  224.           handle_sigfpes(OFF, 0, ...
  225.  
  226.           disables handling of all SIGFPE signals.
  227.  
  228. EEXXAAMMPPLLEESS OOFF CCAALLLLSS TTOO HHAANNDDLLEE__SSIIGGFFPPEESS
  229.      The following example sets up traps of underflow which change the
  230.      resulting value to zero:
  231.  
  232.           #include <sigfpe.h>
  233.  
  234.           /* call this during program startup
  235.              to set underflowing values to zero
  236.           */
  237.  
  238.           void  my_underflow_to_zero(void)
  239.           {
  240.             /* underflow to zero */
  241.  
  242.             sigfpe_[_UNDERFL].repls = _ZERO;
  243.  
  244.             /* only trap on underflow */
  245.  
  246.             handle_sigfpes(_ON, _EN_UNDERFL , 0, _ABORT_ON_ERROR, 0);
  247.           }
  248.  
  249.      The following example counts all traps, traces the first five
  250.      exceptions of each kind, aborts on the first divide by zero, or the
  251.      100th overflow.  It replaces zero for underflows, max float/double for
  252.      overflows, max integer for integer overflows, and the default values
  253.      for divide by zero, invalid operands, and integer overflows.  The
  254.      environment variable example below does the same thing.
  255.  
  256.           #include <limits.h> /* to get INT_MAX */
  257.           #include <sigfpe.h>
  258.  
  259.           main()
  260.           {
  261.             /* underflow to zero */
  262.  
  263.             sigfpe_[_UNDERFL].repls = _ZERO;
  264.  
  265.             /* substitute max float/double on overflow */
  266.  
  267.             sigfpe_[_OVERFL].repls=_MAX;
  268.  
  269.             /* trace first 5 exceptions of each kind */
  270.  
  271.             sigfpe_[_UNDERFL].trace=5;
  272.             sigfpe_[_OVERFL].trace =5;
  273.             sigfpe_[_DIVZERO].trace=5;
  274.             sigfpe_[_INVALID].trace=5;
  275.             sigfpe_[_INT_OVERFL].trace=5;
  276.  
  277.             /* counts at end */
  278.  
  279.             sigfpe_[_UNDERFL].count=INT_MAX;
  280.             sigfpe_[_OVERFL].count =INT_MAX;
  281.             sigfpe_[_DIVZERO].count=INT_MAX;
  282.             sigfpe_[_INVALID].count=INT_MAX;
  283.             sigfpe_[_INT_OVERFL].count=INT_MAX;
  284.  
  285.             /* abort after 100 */
  286.  
  287.             sigfpe_[_UNDERFL].abort=100;
  288.             sigfpe_[_OVERFL].abort =100;
  289.             sigfpe_[_INVALID].abort=100;
  290.             sigfpe_[_INT_OVERFL].abort=100;
  291.  
  292.             /* abort on first divide by zero */
  293.  
  294.             sigfpe_[_DIVZERO].abort=1;
  295.  
  296.  
  297.  
  298.             handle_sigfpes(_ON, _EN_UNDERFL| _EN_OVERFL|_EN_DIVZERO
  299.               | _EN_INVALID | _EN_INT_OVERFL, 0, _ABORT_ON_ERROR, 0);
  300.  
  301.             /* do the real application work here */
  302.           }
  303.  
  304.      The last example shows how to enable different handlers for various
  305.      exception types:
  306.  
  307.           #include <limits.h> /* to get INT_MAX */
  308.           #include <sigfpe.h>
  309.  
  310.           extern user_t  my_invalid_handler;
  311.  
  312.           main()
  313.           {
  314.             /* counts at end */
  315.  
  316.             sigfpe_[_UNDERFL].count=INT_MAX;
  317.             sigfpe_[_OVERFL].count =INT_MAX;
  318.             sigfpe_[_DIVZERO].count=INT_MAX;
  319.             sigfpe_[_INVALID].count=INT_MAX;
  320.             sigfpe_[_INT_OVERFL].count=INT_MAX;
  321.  
  322.             /* enable trapping on overflow, using libfpe's trap handler */
  323.  
  324.             handle_sigfpes(_ON, _EN_OVERFL, 0, 0, 0);
  325.  
  326.             /* enable trapping on invalid, using user's own trap handler */
  327.  
  328.             handle_sigfpes(_ON, _EN_INVALID, my_invalid_handler, 0, 0);
  329.  
  330.             /* do the real application work here */
  331.  
  332.             ....
  333.  
  334.             /* turn off trapping of overflows */
  335.  
  336.             handle_sigfpes(_OFF, _EN_OVERFL, 0, 0, 0);
  337.  
  338.             ....
  339.  
  340.             /* turn off all handling of SIGFPE signals */
  341.  
  342.             handle_sigfpes(_OFF, 0, 0, 0, 0);
  343.  
  344.             ....
  345.  
  346. TThhee TTRRAAPP__FFPPEE EEnnvviirroonnmmeenntt VVaarriiaabbllee
  347.      If the code has been linked with lliibbffppee..ssoo, the runtime startup
  348.      routine will check for the environment variable TTRRAAPP__FFPPEE.  The string
  349.      read as the value of TTRRAAPP__FFPPEE will be interpreted and hhaannddllee__ssiiggffppeess
  350.      will be called with the resulting values.
  351.  
  352.      TTRRAAPP__FFPPEE is read in uppercase letters only.  The string assigned to
  353.      TTRRAAPP__FFPPEE may be in uppercase or lowercase.  TTRRAAPP__FFPPEE can take one of
  354.      two forms: either a global value, or a list of individual items.
  355.  
  356.      Global values:
  357.  
  358.      "" or OFF
  359.           Execute the program with no trap handling enabled.  Same as
  360.           TTRRAAPP__FFPPEE undefined.  Same as linking without lliibbffppee..ssoo
  361.  
  362.      ON   Same as TTRRAAPP__FFPPEE==""AALLLL==DDEEFFAAUULLTT"".
  363.  
  364.           Alternately, replacement values and actions may be specified for
  365.           each of the possible trap types individually.  This is
  366.           accomplished by setting the environment variable as follows:
  367.  
  368.           setenv TRAP_FPE "_i_t_e_m;_i_t_e_m;_i_t_e_m...."
  369.  
  370.      An _i_t_e_m can be one of the following:
  371.  
  372.      traptype=statuslist
  373.           Where traptype defines the specific floating point exception to
  374.           enable, and statuslist defines the list of actions upon
  375.           encountering the trap.
  376.  
  377.      DEBUG
  378.           Confirm the parsing of the environment variable and the trap
  379.           actions.
  380.  
  381.           Traptype can be one of the following literal strings:
  382.  
  383.           UNDERFL
  384.                underflow
  385.  
  386.           OVERFL
  387.                overflow
  388.  
  389.           DIVZERO
  390.                divide by zero
  391.  
  392.           INVALID
  393.                invalid operand
  394.  
  395.           INT_OVERFL
  396.                integer overflow
  397.  
  398.           ALL  all of the above
  399.  
  400.      Statuslist is a list separated by commas.  It contains an optional
  401.      symbolic replacement value, and an optional list of actions.
  402.  
  403.      Symbolic replacement values:
  404.  
  405.      DEFAULT
  406.           Do not override the predefined default values.
  407.  
  408.      IEEE Maps to integer code _APPROPRIATE.
  409.  
  410.      APPROPRIATE
  411.           Maps to integer code _APPROPRIATE.
  412.  
  413.      ZERO Maps to integer code _ZERO.
  414.  
  415.      FLUSH_ZERO
  416.           Maps to integer code _FLUSH_ZERO (R4000 and later processors).
  417.  
  418.      FLUSH_ZERO
  419.           Maps to integer code _ZERO (other processors).
  420.  
  421.      MIN  Maps to integer code _MIN.
  422.  
  423.      MAX  Maps to integer code _MAX.
  424.  
  425.      INF  Maps to integer code _INF.
  426.  
  427.      NAN  Maps to integer code _NAN.
  428.  
  429.           All actions take an optional integer in parentheses:
  430.  
  431.      Note: for any traps that have an action and no specified replacement
  432.      value, the DEFAULT replacement value will be used.
  433.  
  434.      COUNT(_n)
  435.           A count of the trap type will be printed to stderr every nth
  436.           trap, and at the end of the program.  Default is INT_MAX.
  437.  
  438.      ABORT(_n)
  439.           Core dump and abort the program upon encountering the nth trap.
  440.           Default is 1.
  441.  
  442.      EXIT(_n)
  443.           Exit program upon encountering the nth trap.  Default is 1.
  444.  
  445.      TRACE(_n)
  446.           If a trap is encountered, print a stack trace to stderr up to _n
  447.           times.  Default is 10.
  448.  
  449. EEXXAAMMPPLLEESS OOFF TTRRAAPP__FFPPEE
  450.      The following example counts all traps, traces the first five
  451.      overflows, aborts on the first divide by zero, or the 100th overflow.
  452.      It replaces zero for underflows, the "appropriate" value for
  453.      overflows, and the default values for divide by zero, invalid
  454.      operands, and integer overflows.
  455.  
  456.           setenv TTRRAAPP__FFPPEE "ALL=COUNT; UNDERFL=ZERO; OVERFL=IEEE,TRACE(5),
  457.           ABORT(100); DIVZERO=ABORT"
  458.  
  459. WWHHEENN AANN EEXXCCEEPPTTIIOONN IISS EENNCCOOUUNNTTEERREEDD
  460.      When an exception is encountered, the handler examines the instruction
  461.      causing the exception, the state of the floating-point accelerator and
  462.      the sigfpe structure to determine the correct action to take, and the
  463.      program is continued.  In the cases of __UUNNDDEERRFFLL,, __OOVVEERRFFLL,, __DDIIVVZZEERROO,,
  464.      __IINNTT__OOVVEERRFFLL,, and some instances of __IINNVVAALLIIDD,, an appropriate value is
  465.      substituted for the result of the operation, and the instruction which
  466.      caused the exception is skipped.  For most exceptions arising due to
  467.      an invalid operand ( exceptions), more meaningful behavior may be
  468.      obtained by replacing an erroneous operand.  For these conditions, the
  469.      operand is replaced, and the instruction re-issued.
  470.  
  471.      _s_i_g_f_p_e:
  472.           For each enabled exception, the sigfpe structure contains the
  473.           following fields: repls, count, trace, exit and abort.  For each
  474.           enabled exception <_p>, and each non-zero entry <_n> in the sigfpe
  475.           structure, the trap handler will take the following actions:
  476.  
  477.      ccoouunntt::
  478.           A count of all enabled traps will be printed to stderr at the end
  479.           of execution of the program, and every at <_n>th exception <_p>.
  480.  
  481.      ttrraaccee::
  482.           A dbx stack trace will be printed to stderr every exception <_p>,
  483.           up to <_n> times.  You must have dbx installed on your system to
  484.           use this option.
  485.  
  486.      aabboorrtt::
  487.           Core dump and abort program upon encountering the <_n>th exception
  488.           <_p>.  The abort option takes precedence over the exit option.
  489.  
  490.      eexxiitt::
  491.           Exit program upon encountering the <_n>th exception <_p>.
  492.  
  493.      rreeppllss::
  494.           Each of the exceptions __UUNNDDEERRFFLL, __OOVVEERRFFLL, __DDIIVVZZEERROO, and
  495.           __IINNTT__OOVVEERRFFLL has an associated default value which is used as the
  496.           result of the operation causing the exception.  These default
  497.           values may be overridden by initializing this integer value.
  498.           This value is interpreted as an integer code used to select one
  499.           of a set of replacement values, or to indicate that the
  500.           _u_s_e_r__r_o_u_t_i_n_e routine is responsible for setting the value.  These
  501.           integer codes are listed below:
  502.  
  503.      _ZERO
  504.           Use zero as the replacement value
  505.  
  506.      _FLUSH_ZERO
  507.           Set the flush_zero bit in the Control Status register.  This
  508.           causes a flush to zero without invoking the trap handler.  Works
  509.           only for underflow traps on the R4000 and later processors.
  510.           Works like _ZERO for the R3000.
  511.  
  512.      _MIN Use the appropriately-typed minimum value as the replacement
  513.           (i.e., the smallest number which is representable in that format
  514.           without denormalizing).
  515.  
  516.      _MAX Use the appropriately-typed maximum value as the replacement.
  517.  
  518.      _INF Use the appropriately-typed value for infinity as the
  519.           replacement.
  520.  
  521.      _NAN Use the appropriately-typed value for not-a-number as the
  522.           replacement.  (A quiet not-a-number is used.)
  523.  
  524.      _APPROPRIATE
  525.           Use IEEE standard results as the return result for __UUNNDDEERRFFLL,
  526.           __OOVVEERRFFLL, __DDIIVVZZEERROO, and __IINNVVAALLIIDD exceptions.
  527.  
  528.      _USER_DETERMINED
  529.           Invoke the routine _u_s_e_r__r_o_u_t_i_n_e (see note) to set the value of
  530.           the operation.  If this is the code used for  exceptions, all
  531.           such exceptions will defer to _u_s_e_r__r_o_u_t_i_n_e to set their value.
  532.           In this case, _i_n_v_a_l_i_d_o_p__r_e_s_u_l_t_s_ and _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_ will be
  533.           ignored.
  534.  
  535.      _NEG Use the negative of the argument as the replacement operand.
  536.           This code is valid only for the cases __SSQQRRTT__NNEEGG__XX and
  537.           __RRSSQQRRTT__NNEEGG__XX (see below).
  538.  
  539.      The default values used as the results of floating-point exceptions
  540.      are:
  541.  
  542.      ----------------------------------------------------------------------
  543.              Element
  544.        #     mnemonic      Exception condition      Default value
  545.      ----------------------------------------------------------------------
  546.        0    (none)        (ignored)
  547.        1    _UNDERFL      underflow                 _APPROPRIATE
  548.        2    _OVERFL       overflow                  _APPROPRIATE
  549.        3    _DIVZERO      divide-by-zero            _APPROPRIATE
  550.        4    _INVALID      invalid operand           (use tables)
  551.        5    _INT_OVERFL   integer overflow          _MAX
  552.      ----------------------------------------------------------------------
  553.  
  554.      The default values for __UUNNDDEERRFFLL, __OOVVEERRFFLL, __DDIIVVZZEERROO, and __IINNVVAALLIIDD
  555.      exceptions will produce the same results as if the instruction were
  556.      re-issued with the original operand(s) and floating-point traps
  557.      disabled.
  558.  
  559.      Valid values for ssiiggffppee__[[__IINNTT__OOVVEERRFFLL]]..rreeppllss are:  __MMAAXX, AAPPPPRROOPPRRIIAATTEE,
  560.      __ZZEERROO, and __UUSSEERR__DDEETTEERRMMIINNEEDD, the default being __MMAAXX.
  561.  
  562.      For  exceptions, the correct action may be either to set the result
  563.      and skip the instruction, or to replace an operand and retry the
  564.      instruction.  There are four cases in which the result is set.  The
  565.      array named _i_n_v_a_l_i_d_o_p__r_e_s_u_l_t_s_ is consulted for replacement codes for
  566.      these cases:
  567.  
  568.      ----------------------------------------------------------------------
  569.                                                                Default
  570.        #     Element mnemonic         Exception condition      value
  571.      ----------------------------------------------------------------------
  572.        0    (none)                    (ignored)
  573.        1    _MAGNITUDE_INF_SUBTRACTIONoo - oo                  _NAN
  574.        2    _ZERO_TIMES_INF           0 * oo                   _NAN
  575.        3    _ZERO_DIV_ZERO            0/0                      _NAN
  576.        4    _INF_DIV_INF              oo / oo                  _NAN
  577.      ----------------------------------------------------------------------
  578.  
  579.      There are ten cases in which an offending operand is replaced.  An
  580.      array named _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_ is consulted for user-initialized
  581.      codes for these cases.  Cases 8 through 11 are valid only for the
  582.      mips3 and later architectures.  Array _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_ has only 8
  583.      entries (0-7) for the earlier processors.  Each element governs the
  584.      following cases:
  585.  
  586.      ----------------------------------------------------------------------
  587.              Element
  588.        #     mnemonic      Exception condition      Default value
  589.      ----------------------------------------------------------------------
  590.        0    (none)        (ignored)
  591.        1    _SQRT_NEG_X   sqrt(-x)                  reissue
  592.        2    (unused)      (ignored)                 with original
  593.        3    _CVTW_OVERFL  conversion to integer     operands and
  594.                           caused target to
  595.                           overflow
  596.        4    _CVTW_NA      conversion of NaN to iinntt  floating point
  597.        5    _CVTW_INF     conversion of oo to iinntt   traps disabled
  598.        6    _UNORDERED_CMPcomparison to NaN
  599.        7    _SNAN_OP      operand was Signaling
  600.                           NaN
  601.        8    _CVTL_OVERFL  conversion to lloonngg lloonngg
  602.                           caused target to
  603.                           overflow
  604.        9    _CVTL_NAN     conversion of NaN to
  605.                           lloonngg lloonngg
  606.       10    _CVTL_INF     conversion of oo to lloonngg
  607.                           lloonngg
  608.       11    _RSQRT_NEG_X  reciprocal sqrt(-x)
  609.      ----------------------------------------------------------------------
  610.  
  611. WWAARRNNIINNGGSS
  612.      hhaannddllee__ssiiggffppeess is not reentrant.  In particular, it must not be called
  613.      from within an exception handler.
  614.  
  615. NNOOTTEESS
  616.      ""UUssee ooff _u_s_e_r__r_o_u_t_i_n_e ttoo sseett vvaalluueess""
  617.           If the integer code defining the replacement value for a
  618.           particular exception condition is _USER_DETERMINED, the user-
  619.           supplied routine _u_s_e_r__r_o_u_t_i_n_e is called:
  620.  
  621.      ((**uusseerr__rroouuttiinnee))((eexxcceeppttiioonn__ppaarraammeetteerrss,, vvaalluuee));;
  622.      _v_a_l_u_e
  623.           An array of two _i_n_ts into which _u_s_e_r__r_o_u_t_i_n_e should store the
  624.           replacement value.  If an operand is being replaced, _v_a_l_u_e has a
  625.           copy of the current operand.
  626.  
  627.      _e_x_c_e_p_t_i_o_n__p_a_r_a_m_e_t_e_r_s
  628.           An array of five _u_n_s_i_g_n_e_d _i_n_ts which describe the following
  629.           exception condition:
  630.  
  631.      --------------------------------------------------------------------
  632.        #     Element mnemonic         Description
  633.      --------------------------------------------------------------------
  634.        0     _EXCEPTION_TYPE          The exception type (_DIVZERO, etc).
  635.        1     _INVALID_ACTION          value = _SET_RESULT if result is
  636.                                       being set.  value = _REPL_OPERAND
  637.                                       if an operand is being replaced.
  638.                                       This element is meaningful only if
  639.                                       the exception type is .
  640.        2     _INVALID_TYPE            This element is meaningful only if
  641.                                       the exception type is .  It is the
  642.                                       index corresponding to the
  643.                                       particular conditions giving rise
  644.                                       to the exception.  In conjunction
  645.                                       with element 1, this value uniquely
  646.                                       determines the exception condition.
  647.                                       (e.g., if _INVALID_ACTION is
  648.                                       _SET_RESULT and _INVALID_TYPE is 2,
  649.                                       the  exception is due to
  650.                                       _ZERO_TIMES_INF.)
  651.        3     _VALUE_TYPE              The type of the replacement value -
  652.                                       either _SINGLE, _DOUBLE, _WORD, or
  653.                                       _LONGWORD
  654.        4     _VALUE_SIGN    T{        The suggested sign _u_s_e_r__r_o_u_t_i_n_e
  655.                                       should use for the replacement
  656.                                       value - either _POSITIVE or
  657.                                       _NEGATIVE.
  658.      --------------------------------------------------------------------
  659.  
  660. NNOOTTEESS FFOORR RR88000000
  661.      Due to the nature of parallel operations on the R8000 processor, it is
  662.      not possible to determine the true value of the program counter when a
  663.      floating point exception occurs.  Therefore, on that processor,
  664.      lliibbffppee..ssoo will not update either operands or results when floating
  665.      point exceptions occur.  Another anomaly on this processor is that
  666.      counts of floating point exceptions for a particular program may vary
  667.      from run to run.
  668.  
  669.      When the R8000 processor executes in precise exception mode, lliibbffppee
  670.      behaves as it does on other processors, i.e. operands and results can
  671.      be updated when floating point exceptions occur.  See ffppmmooddee(1).
  672.  
  673. SSEEEE AALLSSOO
  674.      ffppcc(3c), ffssiiggffppee(3f), ggeett__ffppcc__ccssrr(3c), sseett__ffppcc__ccssrr(3c), ssiiggnnaall(3c)
  675.  
  676.      This man page is available only online.
  677.  
  678.